import {
    ADD_COUNTER,
    ADD_TO_CART
} from "./mutationstypes"
export default {
    addcart(context, payload) {

        let oldProduct = null
        for (let itme of context.state.cartlist) {
            if (itme.iid === payload.iid) {
                oldProduct = itme
            }
        }
        if (oldProduct) {
            // oldProduct.count += 1
            context.commit(ADD_COUNTER, oldProduct)
        } else {
            payload.count = 1
                // context.state.cartlist.push(payload)
            context.commit(ADD_TO_CART, payload)
        }
    }
}